

#pragma once

#include <vector>
#include <string>
#include <map>

struct xlsWorkBook;
struct xlsWorkSheet;


class ExcelReader
{
public:
    typedef std::vector<std::string> RowVec;
    typedef std::vector<RowVec> RowsVec;

    ExcelReader();

    ~ExcelReader();

    bool open_from_file(const std::string& file, const std::string& ct = "UTF-8");

    bool open_from_string(const std::string& str, const std::string& ct = "UTF-8");

    int rows_count(const std::string& sheet) const;

    int cols_count(const std::string& sheet) const;

    RowVec row(const std::string& sheet, int row) const;

    RowsVec rows(const std::string& sheet) const;
    
    std::string cell(const std::string& sheet, int row, int col) const;

private:
    bool parse_worksheet();
private:
    xlsWorkBook                 *m_pWb;
    struct sheet_info 
    {
        xlsWorkSheet    *psheet;
        std::string     sheet_name;
        int             max_rows;
        int             max_cols;
    };
    std::map<std::string,sheet_info>     sheets;
};